<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%String contextPath = request.getContextPath(); 
    request.setAttribute("contextPath", contextPath);%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>用户管理</title>

    <!-- Bootstrap Core CSS -->
    <link href="${contextPath }/css/bootstrap.min.css" rel="stylesheet">

    <!-- MetisMenu CSS -->
    <link href="${contextPath }/css/metisMenu.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="${contextPath }/css/sb-admin-2.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="${contextPath }/css/font-awesome.min.css" rel="stylesheet" type="text/css">

    <!--common Css-->
    <link href="${contextPath }/css/common.css" rel="stylesheet">
    <link href="${contextPath}/iconfont/iconfont.css" rel="stylesheet">
</head>

<body>

<div id="wrapper">

    <!-- Navigation -->
     <%@include file="nav.jsp"%>

    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h3 class="page-header">用户管理</h3>
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-heading" style="padding-right:30px">
                    <form action="${contextPath}/WebManager/callCenter/getAllUserInfo" method="get" >
                        <div class="row">
                            <div class="col-lg-3 pull-right">
                                <div class="input-group" >
                               		<input type="text" class="form-control" placeholder="请输入搜索内容" name="Dim" id="Dim" value="${Dim}">
                      					<span class="input-group-btn"><input type="submit" class="btn btn-default" value="搜索" id="search" ></span>
                      				
                                
                                </div><!-- /input-group -->
                            </div><!-- /.col-lg-6 -->
                        </div><!-- /.row -->
                        </form>
                    </div>
                    <!-- /.panel-heading -->
                    <c:if test="${result.message!='没有数据' }">
                    <div class="panel-body">
                        <table width="100%" class="table table-striped table-hover" id="dataTables-example">
                            <thead>
                            
                            <tr>
                            	<td>序号</td>
                        		<th>用户ID</th>
                                <th>昵称</th>
                                <th>期数</th>
                                <th>投注金额</th>
                                <th>手机号</th>
                                <th>类别</th>
                                <th>操作</th>
                            </tr>
                          
                            </thead>
                            <tbody>
                            <c:forEach items="${result.list}" var="CallCenter" varStatus="status">
                            <tr class="odd gradeX">
                            	<td>${status.index+1}</td>
                         		<td>${CallCenter.userId}</td>
                                <td>${CallCenter.userName}</td>
                                <td>${CallCenter.expect}</td>
                                <td>${CallCenter.bettingmoney}</td>
                                <td>${CallCenter.phoneNum}</td>
                                <td>${CallCenter.playwayName}</td>
                                
                              <c:if test="${CallCenter.state=='0,1'}">
	                                        <td>
	                                           	用户状态正常
	                                            <button class="btn btn-danger btn-sm" id="state" value="2,3" onclick="jd(${CallCenter.userId},$('#state').val());">冻结</button>
	                                        </td>
                                         </c:if>
                                         <c:if test="${CallCenter.state=='2,3'}">
	                                        <td>
	                                          	 用户状态已冻结
	                                            <button class="btn btn-success btn-sm" id="state1" value="0,1" onclick="jd(${CallCenter.userId},$('#state1').val());">解冻</button>
                                        	</td>
                                         </c:if> 
                            </tr>
                             </c:forEach>
                         
                            </tbody>
                        </table>
                      
                           <div>
                        	<nav aria-label="Page navigation" class="pull-right">
							<ul class="pagination">

								
									<li><a <c:if test="${result.data.pageNow != 1 }">
										href="${contextPath }/WebManager/callCenter/getAllUserInfo?pageNow=${result.data.pageNow-1 }&Dim=${Dim}" </c:if>
										aria-label="Previous"> <span aria-hidden="true">&laquo;</span>
									</a></li>
								
								<%-- <c:if test="${ result.data.pageNow == 1 }">
									<li><a href="#" aria-label="Previous"> <span
											aria-hidden="true">&laquo;</span>
									</a></li>
								</c:if> --%>

							<%-- 	<c:forEach var="i" begin="1" end="${ answer.data.totalPageCount }">

									<c:if test="${ i >= answer.data.pageNow-2 || i <= answer.data.pageNow+2}">
										<c:if test="${ answer.data.pageNow != i }">
											<li><a href="${contextPath}/setup/answer?pageNow=${i}">${ i }</a></li>
										</c:if>
										<c:if test="${ answer.data.pageNow == i }">
											<li><a href="#">${ i }</a></li>
										</c:if>
									</c:if>
									
									<c:if test="${ i <= answer.data.pageNow-2 || i >= answer.data.pageNow+2}">
									</c:if>

								</c:forEach> --%>
								
								<li><input type="text"  disabled="disabled" id="turn" value="${ result.data.pageNow }/${ result.data.totalPageCount }"  style="text-align:center; width: 85px"></li>


								
									<li><a <c:if
									test="${result.data.pageNow != result.data.totalPageCount }">
										href="${contextPath }/WebManager/callCenter/getAllUserInfo?pageNow=${result.data.pageNow+1 }&Dim=${Dim}" </c:if>
										aria-label="Next"> <span aria-hidden="true">&raquo;</span>
									</a></li>
								
								<%-- <c:if
									test="${ result.data.pageNow == result.data.totalPageCount }">
									<li><a href="#" aria-label="Next"> <span
											aria-hidden="true">&raquo;</span>
									</a></li>
								</c:if> --%>
								<li><input type="text" id="jump" style="width:70px"></li>
								
								<li><a href="javascript:turn();">跳转</a></li>
							</ul>
							</nav>
							</div>
							
                    </div>
                    </c:if>
                    <c:if test="${result.message=='没有数据' }">
                    <div style="text-align:center;font-size:2em">
                       		<span style="line-height:400px">没有查询到相关数据</span>
                    </div>
                    
                    </c:if>
                    <!-- /.panel-body -->
                </div>
                <!-- /.panel -->
            </div>
        </div>
    </div>
    <!-- /#page-wrapper -->

    <div class="modal fade" tabindex="-1" role="dialog" id="modal">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">提示信息</h4>
                </div>
                <div id="notice"></div>
                <div class="modal-body">
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" id="sure">确定</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

</div>
<!-- /#wrapper -->

<!-- jQuery -->
<script src="${contextPath }/js/jquery.min.js"></script>

<!-- Bootstrap Core JavaScript -->
<script src="${contextPath }/js/bootstrap.min.js"></script>

<!-- Metis Menu Plugin JavaScript -->
<script src="${contextPath }/js/metisMenu.min.js"></script>

<!-- Custom Theme JavaScript -->
<script src="${contextPath }/js/sb-admin-2.min.js"></script>

<!-- Page-Level Demo Scripts - Tables - Use for reference -->
<script>
	
	
   	
  		$('[data-toggle="popover"]').popover();
  		
  		/* 
    	function jumpMenu(value){
    		var value=$("#select").val();
    		alert(value);
    		location.href="${contextPath }/callCenter/getAllUserInfo?"+value;
    	}
    	
    	

         //冻结按钮
          $("button.btn-danger").on('click', function(){
            var str = '<p>确定要冻结吗?</p>';
            $("#sure").val("0,1");
            $(".modal-body").html(str);
            $("#modal").modal('show');
        }); 

        //解冻按钮
         $("button.btn-success").on('click', function(){
            var str = '<p>确定要解冻吗?</p>';
            $("#sure").val("2,3");
            $(".modal-body").html(str);
            $("#modal").modal('show');
        }); 

        //确定按钮
        $("#sure").click(function(){
            $("#modal").modal('hide');
            var value = $("#sure").val();
            //1是冻结 2是解冻
            $.ajax({
                url: ''
            });
        }); */  
    
        
        

       
         function notice(notice) {
            var str = '';
            str += '<div class="popupTip">';
            str += notice;
            str += '<span class="glyphicon glyphicon-remove"></span>';
            str += '</div>';
            str += '</strong></div>';
            //wrapper插入str
            $("#wrapper").append(str);
        } 

        //取消提示框
        $("#wrapper").on('click', '.glyphicon-remove', function(){
            $(".popupTip") .hide();
        });
    
     
     
         function jd(userId,state){
         	
    		if(confirm("您确定对帐户进行修改吗?")){
    	
    			$.ajax({
     			type:'POST',
 				url:'${contextPath }/WebManager/callCenter/updateUserState',
 				/* data:"{\"userId\":\""+userId+"\",\"state\":\""+state+"\"}",  */
 				data:JSON.stringify({
 					"userId":userId,
 					"state":state
 				}),
 				dataType:'json',
 				contentType: "application/json;charset=utf-8",
 				success:function(data){
 					if(data.message==="200"){
 					var str = '';
 					str += '<div class="alert alert-success" role="alert" id="success">';
 					str += data.message;
 					str += '</div>';
 					$("#notice").html(str);
 					window.location.href = '';
 					}else if(data.message==="400"){
 						$(".popupTip") .hide();
 						notice('修改失败');
 						return false;
 					}
 				},
     		}); 
    	}
    }
   	function turn(){
   		
    	var text = $('#jump').val();
    	var Dim=$('#Dim').val();
    	if(parseInt(text)<=${result.data.totalPageCount}){
    	var reg = /^\+?[1-9][0-9]*$/;
        if (!reg.test(text)) {
        	
        	$(".popupTip") .hide();
        	notice('请输入正整数');
            
            return;
        } 
    	console.log(text);
    	window.location.href = "${contextPath }/WebManager/callCenter/getAllUserInfo?pageNow="+text+"&Dim="+Dim; 
    	
    	}else{
    		return false;
    	}
    	
    }
   </script>


</body>

</html>

